package com.maxima.attendance.listners;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.maxima.attendance.utils.HibernateUtils;

/**
 * Application Lifecycle Listener implementation class HibernateListner
 */
public class HibernateListner implements ServletContextListener {
	/**
	 * Default constructor.
	 */
	public HibernateListner() {
		System.out.println("In the hibernate listner");
	}

	/**
	 * @see ServletContextListener#contextInitialized(ServletContextEvent)
	 */
	public void contextInitialized(ServletContextEvent arg0) {
		HibernateUtils.getSessionFactory();
		System.out.println("Hibernet listner initialised!!");
	}

	/**
	 * @see ServletContextListener#contextDestroyed(ServletContextEvent)
	 */
	public void contextDestroyed(ServletContextEvent arg0) {
		HibernateUtils.getSessionFactory().close();
		System.out.println("Hibernet listner destroyed!!");
	}
}
